package com.starbucks.opencase.tool;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

@Component
public class toolUserWallet {
    @Autowired
    private JdbcTemplate con;
    public void addEnergy(String uid,long energy){
        con.update("update user_wallet set energy=energy+? where uid=?",energy,uid);
    }
    public void subEnergy(String uid,long energy){
        con.update("update user_wallet set energy=energy-? where uid=?",energy,uid);
    }
    public long queryEnergy(String uid){
        return con.queryForObject("select energy from user_wallet where uid=?", Long.class,uid);
    }
}
